// ==UserScript==
// @name            BBS简单辅助 JAE
// @namespace  http://git.oschina.net/jae/tampermonkeyScripts
// @version         0.2
// @description BBS简单辅助,交流QQ群:123266961
// @author         Jaeger <hj.q@qq.com>
// @icon             http://bbs.meizu.cn/favicon.ico
// @require       http://cdn.bootcss.com/coffee-script/1.7.1/coffee-script.min.js
// @include        http://bbs.meizu.cn/*
// @include        http://bbs.flyme.cn/*
// @include        https://member.meizu.com/*
// @include        http://*.xiaomi.cn/*
// @include        http://tieba.baidu.com/*
// @grant        none
// @run-at         document-end
// ==/UserScript==

CoffeeScript.eval((function(){/*
# coffeescript from here ###

(($)->
    class Fbbs
        vClick:(sel)->
            $(sel).length && $(sel)[0].click()
        cList:(lists...)->
            for list in lists
                for sel in list
                   if @vClick(sel) isnt 0 
                        break

    #登陆
    login = [
        #魅族 BBS
        "#mzLoginArea4 a"
        #flyme BBS
        "#loginPanel a:eq(0)"
        ]
    #签到
    sign = [
        #魅族 BBS
        ".btncont_signin_2"
        #flyme BBS
        ".btn_sign_left"
        #小米 BBS
        "#midaben_sign .font"
        #百度贴吧
        ".sign_btn_bright"
    ]
    (new Fbbs).cList login,sign
)(jQuery)

###
功能：延迟批量打开帖子，配合自动回帖用于刷积分,在控制台下手动调用
参数：选择器　延迟时间（毫秒） jQuery
###
window.o=((sel=".xst",delay=10000,$=jQuery)->
       arr = (a.href for a in $(sel))
       index = arr.length - 1
       openurl = -> 
                            url = arr[index]
                            try
                                if not window.opener?.location.href then window.open(url) else window.opener.location.href = url
                            catch e
                                window.open url
                            index-- && setTimeout(openurl,delay)
                            console.log "#{delay/1000}秒后执行下一条。。。。"
        openurl()
    )
# end of coffeescript #*/}).toString().split("\n").slice(1, -1).join("\n"));